#include <iostream>
#include <vector>
using namespace std;
bool find(int* matrix,int rows,int columns,int number)
{
    bool found = false;
    if(matrix!=nullptr&&rows>0&&columns>0)
    {
        int row = 0;
        int column = columns-1;
        while(row<rows&&column>=0)
        {
            if(matrix[row*columns+column] == number)
            {
                found = true;
                break;
            }
            else if(matrix[row*columns+column] > number)
            --column;
        else
            ++row;

        }
    }
    return found;
}
int main() {
    int m,n;
    cin>>m>>n;
    int *matrix = new int[m*n];
    for(int i=0;i<m;i++)
    {
        for(int j=0;j<n;j++)
        {
            cin>>matrix[i*m+j];
        }
    }
    int target;
    cin>>target;
    if(find(matrix,m,n,target))
        cout<<"true";
    else
        cout<<"false";

    return 0;
}